package com.arsn.myf.business.controller;

import com.arsn.myf.common.util.result.R;
import com.arsn.myf.business.service.LeaveService;
import com.arsn.myf.business.vo.LeaveVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 请假任务执行控制层
 * @author zhongrj
 * @since 2022-11-04
 */
@RestController
@RequestMapping("/flow/leave")
@Api(value = "请假任务执行控制层", tags = "请假任务执行控制层")
public class LeaveController {

    @Autowired
    private LeaveService leaveService;

    /**
     * 查询请假的分页数据
     * @param page
     * @param leave
     * @return
     */
    @GetMapping("/page")
    @ApiOperation(value = "查询请假的分页数据")
    public R page(Page<LeaveVO> page, LeaveVO leave){
        return R.data(leaveService.selectLeavePage(page,leave));
    }

    /**
     * 查询详情
     * @param leave
     * @return
     */
    @GetMapping("/getLeaveDetail")
    @ApiOperation(value = "查询详情")
    public R getLeaveDetail(LeaveVO leave){
        return R.data(leaveService.getLeaveDetail(leave));
    }

    /**
     * 启动任务（流程）
     * @param leave
     * @return
     */
    @PostMapping("/start-leave-task")
    @ApiOperation(value = "启动任务")
    public R startLeaveTask(@RequestBody LeaveVO leave){
        return R.status(leaveService.startLeaveTask(leave));
    }
}
